<?php
//$Id: view.php 207 2012-03-14 09:52:26Z tomqin@gmail.com $

/**
 * View 视图类
 *
 * @copyright		Copyright (C) 2010-2012 ARESCMS Inc.
 * @author			TomQin <tomqin@gmail.com>
 * @license			http://www.arescms.cn/license/
 * @package Core
 */

class View{

	private static $data = array();
	private static $tpls = array();

	/**
	 * 设置一个值
	 *
	 * @param string
	 * @param mixed
	 * @return void
	 */
	public static function setVar($key, $var = ''){
		self::$data[$key] = $var;
	}

	/**
	 * 返回一个值
	 *
	 * @param string
	 * @return mixed
	 */
	public static function getVar($key){
		return isset(self::$data[$key]) ? self::$data[$key] : null;
	}

	public static function addView($tplname){
		self::$tpls[] = trim($tplname);
	}

	public static function display(){
		extract(self::$data);
		if(is_array(self::$tpls) && count(self::$tpls)){
			foreach(self::$tpls as $tpl){
				include_once self::getTpl($tpl);
			}
		}
	}

	public static function getTpl($tplname){
		return Config::$items['view.template_path'].$tplname.'.tpl.php';
	}

}
?>